<%@page import="com.wanmait.hotelManage.vo.Pager"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="com.wanmait.hotelManage.vo.Userinfo"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
    String path=request.getContextPath();
    List<Userinfo>userinfos=(List<Userinfo>)request.getAttribute("userinfos");
    %>
                    <table class="result-tab" width="100%">
                         <tr>
                            <th>序号</th>
                            <th>ID</th>
                            <th>用户</th>
                            <th>头像</th>
                            <th>电话</th>
                            <th>城市</th>
                            <th>Vip</th>
                            <th>Vip生效时间</th>
                            <th>Vip结束时间</th>
                            <th>订单信息</th>
                            <th>开户时间</th>
                        </tr>
                        <%
                        if(userinfos!=null){
                        	DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        	for(int i=0;i<userinfos.size();i++){
                        		Userinfo userinfo=userinfos.get(i);
                        		String inputTime=df.format(userinfo.getInputTime());
                        		String vipStartTime=df.format(userinfo.getVipStartTime());
                           		String vipEndTime=df.format(userinfo.getVipEndTime());
                        		%>
                        		<tr>
                            <td><%=i+1 %></td>
                            <td><%=userinfo.getId() %></td>
                            <td><%=userinfo.getUsername() %></td>
                            <td><img  width="50px" height="50px" style="border-radius: 25px;" src="<%=path %>/static/images/touxiang/<%=userinfo.getPic() %>"></td>
                            <td><%=userinfo.getTelephoneNumber() %></td>
                            <td><%=userinfo.getCity().getName() %></td>
                            <td><%=userinfo.getVip().getTitle() %></td>
                            <td><%=vipStartTime %></td>
                            <td><%=vipEndTime %></td>
                            <td><a href="<%=path%>/manage/UserinfoManageServlet?action=OrderInformation&id=<%=userinfo.getId()%>">订单详情</a></td>
                            <td><%=inputTime %></td>
                        </tr>
                        		<%
                        	}
                        }
                        %>
                    </table>
                    <div class="qwe">
                    <%
                    Pager pager=(Pager)request.getAttribute("pager");
                    if(pager!=null){
                    	 int start= 1;
                         int end =pager.getPageCount();
                         if(pager.getPageCount()>5){
                        	 start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
                        	 end=start+4;
                        	 if(end>pager.getPageCount()){
                        		 end=pager.getPageCount();
                        		 start=end-4;
                        	 }
                         }
                         %>
                         [<a class="ok" href="javascript:void(0)">上一页</a>]
                         <%
                    	for(int i=start;i<=end;i++){
                    		if(pager.getPageNo()!=i){
                    		%>
                    		[<a class="number" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}else{
                    		%>
                    		[<a class="aaa" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}
                    }
                         %>
                         [<a class="no" href="javascript:void(0)">下一页</a>]
                         <%
                    }
                    %>
                    </div>
<script>
$(".aaa").css("color","red");
</script>
					<style>
					.qwe{
						text-align:center;
						}
						.aaa{
						text-align:center;
						}
					</style>
					<script>
                    $(function(){
                    	$(".no").click(function(){
							/* $(".number").css("color","black");
							$(this).css("color","red"); */
							var content=<%=pager.getPageNo()%>;
							if(content<<%=pager.getPageCount()%>){
								content++;
							}
							$.ajax({
								url:"<%=path%>/manage/UserinfoManageServlet?action=inittwo",
									data:{pageNo:content},
										success:function(msg){
											$(".result-content").html(msg);
										}
							})
						})
						$(".ok").click(function(){
							/* $(".number").css("color","black");
							$(this).css("color","red"); */
							var content=<%=pager.getPageNo()%>;
							if(content>1){
								content--;
							}
							$.ajax({
								url:"<%=path%>/manage/UserinfoManageServlet?action=inittwo",
									data:{pageNo:content},
										success:function(msg){
											$(".result-content").html(msg);
										}
							})
						})
                    	$(".number").click(function(){
                   		var content=$(this).html();
                   		$.ajax({
                   			url:"<%=path%>/manage/UserinfoManageServlet?action=inittwo",
                   			data:{pageNo:content},
                   			success:function(msg){
                   				console.log(1);
                   				$(".result-content").html(msg);
                   			}
                   		})
                   	})
                   	$(".aaa").click(function(){
                   		var content=$(this).html();
                   		$.ajax({
                   			url:"<%=path%>/manage/UserinfoManageServlet?action=inittwo",
                   			data:{pageNo:content},
                   			success:function(msg){
                   				$(".result-content").html(msg);
                   			}
                   		})
                   	})
                    })
                    </script>